package GUI;

import java.awt.*;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.Iterator;
import java.util.LinkedList;

public class TestFramePaint {
	public static void main(String[] args) {
		new MyFrameA(100,100,500,500);
	}

}

class MyFrameA extends Frame {
	private static final long serialVersionUID = 1L;
	LinkedList<Point> p=new LinkedList<Point>();
	MyFrameA(int x,int y,int width,int height){
		super("MyFrame");
		setBounds(x, y, width, height);
		addMouseListener(new MouseAdapter() {
			public void mousePressed(MouseEvent e) {
				p.add(new Point(e.getPoint()));
				repaint();
			}
		});
		addWindowListener(new WindowAdapter() {
			public void windowClosing(WindowEvent e) {
				setVisible(false);
				System.exit(0);
			}
		});
		addKeyListener(new KeyAdapter() {
			public void keyPressed(KeyEvent e) {
				System.out.println("You Press The Key "+e.getKeyCode());
			}
		});
		setVisible(true);
	}
	
	public void paint(Graphics g) {
		Iterator<Point> i=p.iterator();
		while(i.hasNext()) {
			Point p=i.next();
			g.setColor(Color.green);
			g.fillOval(p.x, p.y, 10, 10);
		}
	}
}